import { join } from 'node:path';

export default () => ({
  port: parseInt(process.env.PORT, 10) || 3000,
  database: {
    mongoUrl: process.env.MONGO_URL || 'mongodb://127.0.0.1:27017/lego',
    mongoUsername: process.env.MONGO_DB_USERNAME || 'root',
    mongoPassword: process.env.MONGO_DB_PASSWORD || '0000',
    authSource: process.env.MONGO_AUTH_SOURCE || 'admin',
  },
  jwt: {
    secret: process.env.JWT_SECRET || 'secret123456',
  },
  redis: {
    host: process.env.REDIS_HOST || 'localhost',
    port: parseInt(process.env.REDIS_PORT, 10) || 6379,
    password: process.env.REDIS_PASSWORD || '',
  },
  Oauth2: {
    github: {
      client_id: process.env.GITHUB_CLIENT_ID,
      client_secret: process.env.GITHUB_CLIENT_SECRET,
      redirectUrl: 'http://localhost:3000/api/users/passport/github/callback',
      getTokenUrl: 'https://github.com/login/oauth/access_token',
      oauthUrl: 'https://github.com/login/oauth/authorize',
      apiBaseUrl: 'https://api.github.com/user',
    },
  },
  h5BaseUrl: 'http://localhost:3000/api/pages',
  upload: {
    dest: join(__dirname, '../../upload/'),
    public: 'upload',
  },
  publicUrl: 'http://localhost:3000',
});
